<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title><%= @title %></title>
		<%= javascript_include_tag :defaults%>
		<%= stylesheet_link_tag "basic.css"%>
	</head>
	<body>
		<div id="container">
			<%= render :partial => "/partial/top" %>
			<%= render :partial => "/partial/head", :locals => { :current_page => "requirement" } %>
			<div id="main">
				<div class="addresses">
		               当前位置：<%= link_to "分度网", SITE %>
		               &gt;
		               <%= link_to "创意需求", :action => :index, :controller =>"site/requirement" %>
		               &gt;
					   <%= link_to @requirement.retype.name, :controller => '/site/requirement', 
															   :action => :detail,
															   :id => @requirement.retype.level%>
		               &gt;
					   <%= @requirement.title%>
		               
		       	</div>
				<div class="need_title">
		            <div class="title"><%= @requirement.title%></div>
		            <ul>           
			          <li>需求编号：<%= @requirement.id%></li>
		              <li>发布者：<%= link_to @requirement.user.username, profile_for(@requirement.user) %></li>
					  <li>评论：<%= @requirement.comments.length%></li>
					  <li>浏览<%= @requirement.click_times%></li>
					  <li>
					  	<div id="store_requirement_<%=@requirement.id%>" class="store_requirement">
				   			<%= link_to_remote "收藏", :url => { :controller => :store,
															:action => :requirement,
															:id => @requirement },
												   :method => :get,
												   :confirm => "确定收藏该需求吗？" %>
				   		</div>
					 </li>
		           </ul>
				   <% if @user == @requirement.user -%>
				   <div id="requirement">
						<%= link_to "编辑", :controller => :requirement, :action => :edit, :id => @requirement%>
						<%= link_to "删除", {:controller => :requirement,
						 				    :action => :destroy, :id => @requirement }, 
					                        :method => :delete, :confirm => "确定删除该需求吗?"%>
				   </div>	
				   <% end %>	
		        </div>
				<table cellspacing="0" cellpadding="2" border="0" width="100%" class="cvlistTable">
					<tbody>
						<tr>
							<td width="21%"><span class="blue">需求描述：</span> </td>
							<td><%= simple_format @requirement.content -%></td>
						</tr>
						<tr>
							<td width="21%"><span class="blue">最大预算：</span></td>
							<td><span class="hei"><%= @requirement.price -%></span>&nbsp;</td>
						</tr>
						<tr>
							<td width="21%"><span class="blue">需求有效期(天数):</span></td>
							<td>
								<span class="hei">
									<%begin_date = @requirement.created_at.to_date%>
									<%end_date = begin_date+@requirement.expiration.to_i%>
									<%= begin_date.to_s -%>——
									<%= end_date.to_s -%>
								</span>
							</td>
						</tr>
						<% if @requirement.attach.exists?%>
						<tr>
							<td>附件：</td>
							<td><%= render :partial => "download_requirement" %></td>
						</tr>
						<% end %>		
					</tbody>
				</table>
				<% if @login_user.role == DESIGNER %>
				<% form_for :comment, :url => { :controller => :requirement, 
												:action =>  :show },
									  :html => { :multipart => true, :class => "quote" }  do |f|%>
					<p>我要竞标</p>
					<%= text_field_for f, :price, @comment, { :text => "我的报价", :required => true } %><span>元</span>
					<%= text_field_for f, :need_days, @comment, { :text => "交付周期", :required => true } %><span>天</span>						
					<%= text_area_for f, :content, @comment, { :text => "创意描述", :required => true } %>
					<%= render :partial => "attach_comment", :locals => { :f => f}%>
					<div class="field">
						<label for="hidden">隐藏</label>
						<%= f.check_box :hidden%>
					</div>
					<%= submit_tag "竞标", :class => "btn", :disabled => Time.now.to_date > end_date %>	
				<% end %>
				<% end %>
                <div class="allworks">
		          <div class="ati">所有作品<span><%=@requirement.comments.length%></span></div>
		          <div class="atc">
		        	<p class="">排序：</p>
		            <select name="">
		                 <option value="Sort">最新作品在前</option>
		                 <option value="Sort">最先发布作品在前</option>            
		            </select>
		               <p class="">搜索：</p>    
		             <select name="">
		                 <option value="Sort">按昵称查找</option>
		                 <option value="Sort">按作品号查找</option>            
		            </select>
		            <input type="text" class="text_serch" name="workskey" id="workskey" /> 
		            <input type="button" value="搜索" class="btn" name="" />         
		          </div>
        		</div>    
				<%@comments = @requirement.comments.paginate(:page => params[:page],
                                               :per_page => PERPAGE,
                                               :order => "created_at DESC")%>                    
				<%= will_paginate @comments%>
				<%= render :partial => "comment/comment", :collection => @comments%>
			</div>
			<div id="footer">
				<ul>
				    <li><a href="#">关于分度</a></li> 
		            <li><a href="#">服务指南</a></li>
		            <li><a href="#">网站导航</a></li>
					<li><a href="#">诚聘英才</a></li>
				    <li><a href="#">战略伙伴</a></li>
				    <li><a href="#">联系我们</a></li>
				</ul>
	  		</div>
  
		  	<div id="dibu">电信经营许可证号 广告经营许可证号 工商注册登记号
		  		<br> COPYRIGHT@2008年-2009年 FENDU . ALL RIGHTS RESERVED
		  	</div>
		</div>
	</body>
</html>